import { BADGE_STATUS_LIST } from '@/const/type';
export const tableOption = (flag) => {
  return {
    ...window.$crudMixins.tableOptions,
    viewBtn: false,
    addBtn: true,
    editBtn: false,
    delBtn: false,
    labelWidth: 130,
    searchLabelWidth: 90,
    span: 12,
    menuWidth: 120,
    column: [
      {
        label: '徽章名称',
        prop: 'name',
        row: true,
        search: true,
        rules: [
          {
            required: true,
            message: '请输入徽章名称',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '徽章slogan',
        prop: 'slogan',
        row: true,
      },
      {
        label: '徽章描述',
        prop: 'description',
        row: true,
        // addDisplay: false,
        // editDisplay: false,
        // viewDisplay: false,
        rules: [
          {
            required: true,
            message: '请输入徽章描述',
          },
          {
            min: 1,
            max: 40,
            message: '长度不能超过40个字符',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '徽章描述提示',
        prop: 'tips',
        row: true,
        rules: [
          {
            min: 1,
            max: 30,
            message: '长度不能超过30个字符',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '完成目标',
        prop: 'targetQty',
        type: 'number',
        value: 1,
        precision: 0,
        min: 0,
        max: 1000,
        width: 100,
        editDisabled: flag,
        rules: [
          {
            required: true,
            message: '请输入完成目标',
            trigger: 'blur',
          },
        ],
        row: true,
      },
      {
        label: '徽章未点亮图标',
        prop: 'defaultIcon',
        type: 'upload',
        listType: 'picture-img',
        // listType: 'picture-card',
        fileSize: 10 * 1024,
        fileType: 'img', //img/video/audio
        propsHttp: {
          name: 'hash',
          url: 'key',
        },
        oss: 'qiniu',
        // cropperOption: {
        //   // autoCropWidth: 187.5,
        //   // autoCropHeight: 250,
        //   enlarge: 2,
        //   fixed: true,
        //   fixedNumber: [1, 1], // 截图框的宽高比例
        // },
        tip: '请上传jpg/png/jpeg/webp/heic类型的文件，且大小不超过10M',
        row: true,
        span: 24,
        limit: 1,
        accept: '.jpg,.png,.jpeg,.webp,.heic',
        rules: [
          { required: true, message: '请上传徽章未点亮图标', trigger: 'blur' },
        ],
      },
      {
        label: '徽章已点亮图标',
        prop: 'lightUpIcon',
        type: 'upload',
        listType: 'picture-img',
        // listType: 'picture-card',
        fileSize: 10 * 1024,
        fileType: 'img', //img/video/audio
        propsHttp: {
          name: 'hash',
          url: 'key',
        },
        oss: 'qiniu',
        // cropperOption: {
        //   // autoCropWidth: 187.5,
        //   // autoCropHeight: 250,
        //   enlarge: 2,
        //   fixed: true,
        //   fixedNumber: [1, 1], // 截图框的宽高比例
        // },
        tip: '请上传jpg/png/jpeg/webp/heic类型的文件，且大小不超过10M',
        row: true,
        span: 24,
        limit: 1,
        accept: '.jpg,.png,.jpeg,.webp,.heic',
        rules: [
          { required: true, message: '请上传徽章已点亮图标', trigger: 'blur' },
        ],
      },
      {
        label: '状态',
        prop: 'status',
        type: 'select',
        dicData: BADGE_STATUS_LIST,
        addDisplay: false,
        editDisplay: false,
      },
      {
        label: '排序',
        prop: 'sort',
        type: 'number',
        value: 1,
        precision: 0,
        min: 0,
        max: 100,
        width: 100,
        rules: [
          {
            required: true,
            message: '请输入排序',
            trigger: 'blur',
          },
        ],
        row: true,
      },
      {
        label: '创建时间',
        prop: 'createTime',
        width: 150,
        addDisplay: false,
        editDisplay: false,
        viewDisplay: false,
      },
    ],
  };
};
